if modifier_ring_gains == nil then modifier_ring_gains = class({}) end
LinkLuaModifier("modifier_ring_gains", "abilities/ability_ring_gains", LUA_MODIFIER_MOTION_NONE)


if ability_ring_gains == nil then ability_ring_gains = class({}) end

function ability_ring_gains:GetIntrinsicModifierName()
	return "modifier_ring_gains"
end

function modifier_ring_gains:DeclareFunctions()
	local funcs = {
		MODIFIER_PROPERTY_TOOLTIP2,
		MODIFIER_PROPERTY_REINCARNATION
	}

	return funcs
end

function modifier_ring_gains:ReincarnateTime()
	return self:GetAbility():GetSpecialValueFor("interval")
end

function modifier_ring_gains:OnTooltip2()
 	return self:GetAbility():GetSpecialValueFor("bonus_gold")
end

function modifier_ring_gains:GetTexture()
	return "alchemist_goblins_greed"
end

function modifier_ring_gains:GetAttributes()
	return MODIFIER_ATTRIBUTE_PERMANENT + MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE
end

function modifier_ring_gains:IsPurgable()
	return false
end

function modifier_ring_gains:OnCreated()
	if IsServer() then
		self.interval = self:GetAbility():GetLevelSpecialValueFor("interval",0)
		self:StartIntervalThink(1)
		self:SetStackCount(self.interval)
	end
end


function modifier_ring_gains:OnIntervalThink()
	--print("modifier_ring_gains:OnIntervalThink")
	if IsServer() then
		if self:GetStackCount()==1 then
			local bonus_xp=0
			if (self:GetParent():GetLevel()+1)<=#HeroConfig then
				local heroLvConfig=HeroConfig[self:GetParent():GetLevel()+1]
				bonus_xp = math.ceil(self.interval*(heroLvConfig.xp/heroLvConfig.levelUpTime))
			end
			local bonus_gold=self:GetAbility():GetLevelSpecialValueFor("bonus_gold",self:GetAbility():GetLevel()>0 and self:GetAbility():GetLevel()-1 or 0)
			self:GetParent():AddExperience(bonus_xp, 0, false, false )
			self:GetParent():ModifyCustomGold(bonus_gold)
			SendOverheadEventMessage(PlayerResource:GetPlayer(self:GetParent():GetPlayerID()),OVERHEAD_ALERT_GOLD, self:GetParent(), bonus_gold, nil)
			self:SetStackCount(self.interval)
		else
			self:DecrementStackCount()
		end

	end
end

